<?php
include '../includes/cDatabase.php';
include '../includes/variables.php';
include '../includes/cPage.php';
include '../includes/cDates.php';

$cPage = new page("Update Remove Player");
echo $cPage->getTitle();
echo $cPage->pageStringStart();
echo $cPage->contentStringStart();

$selectArray = array();

$cDatabase = new database();

$connect = $cDatabase->connectToDatabase();
$activeDatabase = $cDatabase->getActiveDatabase($connect);
	
$db = $cDatabase->selectDatabase($connect, $activeDatabase);

$selectArray[0] = '*';
$result = $cDatabase->selectFromDatabase($connect, 'playerlist', $selectArray, NULL, NULL, NULL, NULL);

if ($result)
{
	echo "<table border='1'><thead><tr>";
	echo "<th></th><th></th>";
	
	$finfo = mysqli_fetch_fields($result);
	for($i = 0; $i < mysqli_num_fields($result); $i++)
	{
		if($finfo[$i]->name == 'playerCode' || $finfo[$i]->name == 'playerName' || $finfo[$i]->name == 'playerTeam' || $finfo[$i]->name == 'playerValue' || $finfo[$i]->name == 'playerPosition')
		{
			echo "<th>" .$finfo[$i]->name."</th>";
		}
	}
	echo "  </tr></thead><tbody>";

	for ($i = 0; $i < mysqli_num_rows($result); $i++)
	{
		$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
		
		echo "<tr><td> <input type='BUTTON' value='Remove' onclick='window.location.href=\"DB_ProcessRemovePlayer.php?playerCode=".$row['playerCode']."\"'></td>";
		echo "<td> <input type='BUTTON' value='Update' onclick='window.location.href=\"DB_ProcessUpdatePlayer.php?playerCode=".$row['playerCode']."\"'></td>";
		echo "<td>".$row['playerCode']."</td>";
		echo "<td>".$row['playerName']."</td>";
		echo "<td>".$row['playerTeam']."</td>";
		echo "<td>".$row['playerValue']."</td>";
		echo "<td>".$row['playerPosition']."</td></tr>";
	}
	echo "</tbody>
	</table>";
}  //end else
echo $cPage->getContentStringEnd();
echo $cPage->getMenu();
echo $cPage->getClear();
echo $cPage->pageStringEnd();
?>
